package avicit.bdp.dds.dao.mapper;

import avicit.bdp.common.base.BaseDAO;
import avicit.bdp.dds.dao.entity.Project;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * project mapper interface
 */
public interface ProjectMapper extends BaseDAO<Project> {

    /**
     * query project detail by id
     *
     * @param projectId projectId
     * @return project
     */
    Project queryDetailById(@Param("projectId") int projectId);

    /**
     * query project by name
     *
     * @param projectName projectName
     * @return project
     */
    Project queryByName(@Param("projectName") String projectName);

    /**
     * project page
     *
     * @param userId     userId
     * @param searchName searchName
     * @return project Ipage
     */
    Page<Project> queryProjectListPaging(@Param("userId") String userId,
                                         @Param("searchName") String searchName);

    /**
     * query create project user
     *
     * @param userId userId
     * @return project list
     */
    List<Project> queryProjectCreatedByUser(@Param("userId") int userId);

    /**
     * query authed project list by userId
     *
     * @param userId userId
     * @return project list
     */
    List<Project> queryAuthedProjectListByUserId(@Param("userId") int userId);

    /**
     * query project except userId
     *
     * @param userId userId
     * @return project list
     */
    List<Project> queryProjectExceptUserId(@Param("userId") int userId);

    /**
     * @param userId
     * @param keyWords
     * @return
     */
    Page<Project> getList(@Param("userId") String userId,
                          @Param("keyWords") String keyWords);

    /**
     * 根据id删除数据源
     *
     * @param projectId
     */
    void deleteDatasourceById(@Param("projectId") String projectId);

    /**
     * 根据项目id删除自己创建的表
     *
     * @param projectId
     * @param imported
     */
    void deleteTableById(@Param("projectId") String projectId, @Param("imported") Integer imported);

    List<Project> getListFirstProject(String userId);

    /**
     * 根据userID查询项目空间
     *
     * @param userId
     * @return
     */
    List<Project> getProjectByUserId(String userId);

    List<Project> getAllDevProjectList(@Param("userId") String userId, @Param("projectType") String projectType,
                                       @Param("wordSecretList") List<String> wordSecretList);

    String getResourceEngineIdByTaskId(@Param("taskId") String taskId);

    Integer selectResourceType(@Param("projectId") String projectId);

    //查询数据空间是否有数据发布
    int selectCountDataResource(@Param("projectId") String projectId);
}
